<?php
	ob_start();
	
	class pages extends CI_Controller
	{
		public function __construct()
		{
			parent::__construct();
			$this->load->model('pagesModel');
			
			$this->pages = array(
				'about'			=>	'About us',
				'vendor'		=>	'Vendor Programme',
				'career'		=>	'Careers',
				'advertising'	=>	'Advertising',
			);
			
			$this->load->helper('url');
			$this->load->helper('form');
			$this->load->model('Jobs');
		}
		
		public function index()
		{
			recirect(base_url());
		}
		
		public function view($page)
		{
			$this->load->library('Menu');
			$menu = new Menu;
			$user =& Users::getInstance();
			$data = $menu->gen();
			$data['user'] = $user;
			
			if ($user->level > 0) {
				$data['stats']['oncoming'] = $this->Jobs->getOncoming(-1, true);
				$data['stats']['quote'] = $this->Jobs->getNeedQuote(-1, true);
			}
			
			if(isset($page) && strlen($page) > 0)
			{
				if($query = $this->pagesModel->find($page))
				{
					$data['page'] = $query;
					$data['pageTitle'] = $this->pages[$page];
				
					$this->load->view('pages.php', $data);
				}
			}
			else
			{
				redirect(base_url());
			}
		}
	}
?>